package com.kfm.advice;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

//处理所有的springmvc异常
@ControllerAdvice
public class MyControllerAdvice {

    @ExceptionHandler({RuntimeException.class,Exception.class})
    public ModelAndView doEx(){
        ModelAndView mv = new ModelAndView();
        mv.addObject("mseeage","服务器内部错误");
        mv.setViewName("error");
        return mv;
    }
}
